package com.hula.onion.book.server.spider.platforms.wanyingjinrong;

import com.hula.onion.book.server.common.CommonResponse;
import com.hula.onion.book.server.common.SpiderCommon;
import com.hula.onion.book.server.utils.HttpUtils;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.BasicCookieStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * Created by work on 2018/1/26.
 */
@Component("wanYingJinRongSpider")
public class WanYingJinRongSpider extends SpiderCommon{
    @Autowired
    private WanYingJinRongSpiderHelper spiderHelper;

    private static final String LOGIN_URL="https://www.wyjr168.com/Home/Login?sid=0.12984882949512233";

    @Override
    public CommonResponse execute() {
        HttpClientContext httpContext=new HttpClientContext();
        BasicCookieStore cookieStore=new BasicCookieStore();
        httpContext.setCookieStore(cookieStore);
        Map<String,Object> params=spiderHelper.installRequestParams(loginForm);
        String sid="0."+String.valueOf(System.currentTimeMillis());
        System.out.println(sid);
        String loginStr= HttpUtils.post(LOGIN_URL,params,httpContext);
        System.out.println(loginStr);
        return null;
    }
}
